PROJECT = "lcddemo"
VERSION = "1.0.0"

log.info("main", PROJECT, VERSION)

-- sys库是标配
_G.sys = require("sys")

---需要在云编译时添加SPI协议
spi_lcd = spi.deviceSetup(2, 7, 0, 0, 8, 40000000, spi.MSB, 1, 1) -- https://wiki.luatos.com/api/spi.html
-- spi.setup(id, cs, CPHA, CPOL, dataw, bandrate, bitdict, ms, mode)

lcd.init("st7789", {
    port = "device",
    pin_dc = 6,
    pin_pwr = 11,
    pin_rst = 10,
    direction = 0,
    w = 240,
    h = 320,
    xoffset = 0,
    yoffset = 0
}, spi_lcd)
-- 如果显示颜色相反，关闭反色
lcd.invoff()

sys.taskInit(function()

    sys.wait(1000)
    log.info(wlan.init())
    wlan.setMode(wlan.STATION)
    wlan.connect("ESP32", "776654321")


    while not wlan.ready() do
        log.info("Disconnection")
        sys.wait(1000)
    end
    log.info("ready !!")


end)

-- 用户代码已结束---------------------------------------------
-- 结尾总是这一句
sys.run()
-- sys.run()之后后面不要加任何语句!!!!!
